﻿Public Class cakeTag
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If User.Identity.IsAuthenticated Then
            'Excellent no problem
        Else
            'Redirect to home
            Response.Redirect("opps.aspx?id=1")
        End If
    End Sub

    Protected Sub btn_tag_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_tag.Click
        Dim cakeId As Integer = Request.Params("cakeId")
        'Add the cake Tags (pre existing)
        For Each item As ListItem In cbl_tags.Items
            If item.Selected = True Then
                Class1.addTag(item.Value, cakeId)

            End If

        Next

        'Add the new cake Tags (check if in first)
        If tb_tags.Text = "" Then
            'Do Nothing
        Else
            Dim tags As String
            tags = tb_tags.Text
            Dim splitTags As String() = tags.Split(",")
            Dim tag As String
            For Each tag In splitTags
                Class1.addNewTag(tag, cakeId)
            Next
        End If
        Class1.addCakePoint(Class1.getUserNumber(User.Identity.Name), 1, "Cake Tag")

        Response.Redirect("details.aspx?cakeNo=" & cakeId)
    End Sub
End Class